//
//  GLFormViewController.h
//  KTools
//
//  Created by 121 on 2017/9/28.
//  Copyright © 2017年 杭州吉利控股信息中心. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "GLFormKit.h"
#if __has_include("GLBaseViewController.h")
#import "GLBaseViewController.h"
#endif
typedef NS_ENUM(NSInteger, GLErrorCode) {
    GLErrorCodeNone = 0,
    GLErrorCodeValueNil,
    GLErrorCodeValueValid,
};


@class GLFormError;
@class GLError;
#if __has_include("GLBaseViewController.h")
@interface GLFormViewController : GLBaseViewController
#else
@interface GLFormViewController : UIViewController
#endif
@property(nonatomic,strong)UITableView* tableView;
@property(nonatomic,assign)BOOL immediRefresh; //加载后立即刷新
@property(nonatomic,assign)BOOL showCornerForm; //defautl NO
@property(nonatomic,assign)BOOL shouldPullRefresh; //default NO
@property(nonatomic,assign)BOOL shouldLoadMore; //default NO
@property(nonatomic,assign)BOOL hideLoadMore;
-(void)endRefresh;
-(void)endLoadMore;

//need override
-(void)formShouldLoadMoreData;
-(void)formShouldReloadData;


@property(nonatomic,strong)GLForm* form;



-(NSArray<GLFormRow *> *)formRowsWithTag:(NSString *)tag;
-(GLFormRow *)formRowAtIndex:(NSIndexPath *)indexPath;
-(NSIndexPath *)indexPathForFormRow:(GLFormRow *)formRow;
-(GLFormSection *)formSectionAtIndex:(NSUInteger)index;
-(NSInteger)IndexformSection:(GLFormSection*)section;


- (void)reloadFormRow:(GLFormRow*)row;
- (void)reloadFormSection:(GLFormSection*)section;
- (void)reloadSection:(NSUInteger)section;
- (void)reloadSections:(NSIndexSet *)sections;
- (void)reloadData;

-(NSDictionary *)formValues;
-(GLFormError*)validateFormValues;
/*
 *@override
 */
-(void)formRowClicked:(GLFormRow*)row;
-(void)formRow:(GLFormRow*)row eventClicked:(id)send subTag:(NSString*)subTag;
@end


#pragma mark- class GLFormError

@interface GLFormError : NSError
@property(nonatomic,copy)NSString* tag;
@end


#pragma mark- class GLFormOptionViewController
@interface GLFormOptionViewController : GLFormViewController
@property(nonatomic,weak)GLFormRow* formRow;
@property(nonatomic,assign)GLFormRowAction actionType;
@property(nonatomic,strong)NSString* labelTitle;
@property(nonatomic,strong)NSString* navTitle;

@property(nonatomic,strong)NSArray* options;
@end
